package com.seal.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.seal.comm.utils.Page;
import com.seal.dao.IValidateDao;
import com.seal.dto.ValidateDto;
import com.seal.model.Validate;
import com.seal.service.IValidateService;

@SuppressWarnings("unchecked")
@Service("validateServiceImpl")
@Transactional(readOnly = true)
public class ValidateServiceImpl implements IValidateService {

	@Resource(name = "validateDaoImpl")
	private IValidateDao validateDao;

	@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
	public void addValidate(Validate validate) throws Exception {
		validateDao.addValidate(validate);
	}

	public List<Validate> getAllValidates(ValidateDto validateDto, Page page)
			throws Exception {
		return validateDao.getAllValidates(validateDto, page);
	}

	public Validate getValidateBySeqId(String seqId, Long companyId) throws Exception {
		return validateDao.getValidateBySeqId(seqId, companyId);
	}

	public Validate getValidateByValId(String valid) throws Exception {
		return validateDao.getValidateByValId(valid);
	}

	public int getValidateCountByOrderId(Long orderId) throws Exception {
		return validateDao.getValidateCountByOrderId(orderId);
	}

	@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
	public void updateValidate(Validate validate) throws Exception {
		validateDao.updateValidate(validate);
	}

	@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
	public void updateStatusByOrderId(Long orderId) throws Exception {
		validateDao.updateStatusByOrderId(orderId);
	}

	@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
	public void deleteValidateByOrderId(Long orderId) throws Exception {
		validateDao.deleteValidateByOrderId(orderId);
	}

}
